// vuex的权限模块
import { constantRoutes, asyncRoutes } from '@/router/index.js'

const state = {
  routes: constantRoutes
}
const mutations = {
  setRoutes(state, filterRoutes) {
    // console.log(filterRoutes)
    state.routes = [...constantRoutes, ...filterRoutes]
  }
}
const actions = {
  filterRoutes(context, menus) {
    // const filterRouters = asyncRoutes.filter(t => menus.includes(t.name))
    const filterRouters = asyncRoutes
    context.commit('setRoutes', filterRouters)
    return filterRouters
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
